/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/



#if !defined(AFX_PGLLINEARGRADIENTBRUSH_H__C52225B7_9F39_4BD0_8AEC_85049DA332A5__INCLUDED_)
#define AFX_PGLLINEARGRADIENTBRUSH_H__C52225B7_9F39_4BD0_8AEC_85049DA332A5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/core/PGLObject.h>
#include <pgl/core/PGLBrush.h>
#include <pgl/core/PGLColor.h>

/*! \brief Linear gradient brush

  \ingroup PGLBrushGroup
*/
class PGLCORE_EXT_CLASS CPGLLinearGradientBrush : public CPGLBrush  
{
PGL_DECLARE_DYNCREATE(CPGLLinearGradientBrush);
public:
	//! \name Constructors
	//@{
	//! Default constructor
	CPGLLinearGradientBrush(
		const CPGLColor& cStart = CPGLColor(0,0,0),
		const CPGLColor& cEnd = CPGLColor(1,1,1),
		double dAngle=0,
		const CPGLRectD& rBBox = CPGLRectD::GetNormBox());
	//! Copy constructor
	CPGLLinearGradientBrush(const CPGLLinearGradientBrush& brush)	{*this = brush;};
	//! Assignment constructor
	CPGLLinearGradientBrush& operator = (const CPGLLinearGradientBrush& brush);
	virtual ~CPGLLinearGradientBrush();
	//@}

	//! \name Getters and Setters
	//@{
	//! return reference to start color
	CPGLColor& GetStartColor()									{	return m_cStart;};
	//! return const reference to start color
	const CPGLColor& GetStartColor()	const					{	return m_cStart;};
	//! Sets start color
	void SetStartColor(const CPGLColor& col)					{	m_cStart=col;};
	//! Sets start color with red = r, green = g, blue = b and alpha = a. r,g,b,a must be in [0,1]
	void SetStartColor(float r, float g, float b, float a = 1)	{	m_cStart.SetColor(r,g,b,a);};

	//! return reference to end color	
	CPGLColor& GetEndColor()									{	return m_cEnd;};
	//! return const reference to end color	
	const CPGLColor& GetEndColor()	const						{	return m_cEnd;};
	//! Sets end color
	void SetEndColor(const CPGLColor& col)						{	m_cEnd=col;};
	//! Sets end color with red = r, green = g, blue = b and alpha = a. r,g,b,a must be in [0,1]
	void SetEndColor(float r, float g, float b, float a = 1)	{	m_cEnd.SetColor(r,g,b,a);};

	//! Returns angle of gradient (in degrees, counter-clock wize)
	double GetAngle() const										{	return m_dAngle;};
	//! Set angle of gradient (in degrees, counter-clock wize)
	void SetAngle(double angle)									{	m_dAngle = angle - 360*((int)floor(angle/360));};
	//@}

	//! \name Plotting functions
	//@{
	//! Make brush current in graphic interface
	virtual void MakeCurrentFill(gfxinterface::CGfxInterface& gfx);
	//@}

	//! \name Serialization and debugging
	//@{
	//! Serialize functions
	virtual void SerializeXML(CPGLArchive& ar);

	//! Debuggin functions
	#ifdef _DEBUG
	    virtual void Dump( CDumpContext& dc ) const;
	    virtual void AssertValid() const;  
	#endif
	//@}
protected:
	//! \name Attributes
	//@{
	//! Start color
	CPGLColor m_cStart;
	//! End color
	CPGLColor m_cEnd;
	//! Angle of gradient (in degrees, counter-clock wize)
	double m_dAngle;
	//@}
};

PGL_DECLARE_SMARTPTR( CPGLLinearGradientBrush );

#endif // !defined(AFX_PGLLINEARGRADIENTBRUSH_H__C52225B7_9F39_4BD0_8AEC_85049DA332A5__INCLUDED_)
